const Koa = require('koa')
const app = new Koa()
const json = require('koa-json')//美化JSON
const onerror = require('koa-onerror')
const bodyparser = require('koa-bodyparser')
const logger = require('koa-logger')
const InitManager=require('./core/init')
const catchError=require('./middlewares/exception') //全局错误导出 如服务器五百等问题
const morganError=require('./middlewares/morgan') //全局错误导出 如服务器五百等问题
const static = require('koa-static')
const path = require('path')
const morgan = require('koa-morgan')//错误日记
require('module-alias/register')//别名
onerror(app) 
morganError.catchErrorCore(app)
app.use(catchError)
app.use(bodyparser({
  enableTypes: ['json', 'form', 'text']
}))
app.use(json())
app.use(logger())
InitManager.initCore(app)


app.use(static(path.join(__dirname,'./static')))




module.exports = app
